﻿Imports Microsoft.VisualBasic
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.Collections.Generic

Public Class AppDataContext
    Public Shared ReadOnly Property Instance As AppDataContext
        Get
            If (HttpContext.Current.Session(HttpContext.Current.Session.SessionID) Is Nothing) Then
                HttpContext.Current.Session.Add(HttpContext.Current.Session.SessionID, New AppDataContext())
            End If

            Return HttpContext.Current.Session(HttpContext.Current.Session.SessionID)
        End Get
    End Property

    Private Shared Sub Save()
        HttpContext.Current.Session(HttpContext.Current.Session.SessionID) = AppDataContext.Instance
    End Sub

    Private Shared _Users As Users
    Private Shared _RolesToUsers As RolesToUsers

    Public Shared Property User() As Users
        Get
            Return _Users
        End Get
        Set(ByVal value As Users)
            _Users = value
            Save()
        End Set
    End Property
    Public Shared Property RoleID() As RolesToUsers
        Get
            Return _RolesToUsers
        End Get
        Set(ByVal value As RolesToUsers)
            _RolesToUsers = value
            Save()
        End Set
    End Property
End Class
